<?php
class ModelNewsType extends Model {
	public function getNewsTypes(){
		$key = 'news.type.' . (int)$this->config->get('config_language_id');

		$news_type_data = $this->cache->get($key);

		if (!$news_type_data) {
			$sql  = " SELECT * FROM " . DB_PREFIX . "news_type nt ";
			$sql .= " LEFT JOIN " . DB_PREFIX . "news_type_description ntd ON (nt.type_id = ntd.type_id) ";
			$sql .= " WHERE ntd.language_id ='" . (int)$this->config->get('config_language_id') . "'";
			$sql .= " ORDER BY sort_order ASC";
			$query = $this->db->query($sql);

			$news_type_data = $query->rows;

			$this->cache->set($key, $news_type_data);
		}

		return $news_type_data;
	}

	public function getNewsType($type_id) {
		$sql  = " SELECT * FROM " . DB_PREFIX . "news_type nt ";
		$sql .= " LEFT JOIN " . DB_PREFIX . "news_type_description ntd ON (nt.type_id = ntd.type_id) ";
		$sql .= " WHERE ntd.language_id ='" . (int)$this->config->get('config_language_id') . "'";
		$sql .= " AND nt.type_id = '" . $type_id . "'";

		$query = $this->db->query($sql);

		return $query->row;
	}
}
?>